<div style="font-size: 0.7em; font-family:arial;"> 
    <?php echo $unidadfuncional->getContribuyente(); ?><br>
    <?php echo $unidadfuncional->getCalle() . " " . $unidadfuncional->getNro() . " - " . $unidadfuncional->getBarrio(); ?><br>
    <?php echo $unidadfuncional->getBarrio()->getZona() . " COLONIA POPULAR" ?>
</div>
<?php $lact = 0;
      $lant =0;
      $totalfijos = 0;
      $valormts3 = 0;
      $total = 0;
      ?>
<div style="width:200mm">
    <span style="text-align: center;height:10mm">Pago correspondiente a la factura nro.: <?php echo $unidadfuncional->getComprobante()->getLast()->getNroComprobante()?></span>
    <hr>
    <br>
    <div style="width:200mm">
        <table border="0">
            <tbody>
               <?php if(count($lectura)): ?>
                <tr>
                    <td width="100%"> 
                      
                        <table border="1">
                            <tr>
                                <th style="background-color: #CACACA; width: 40mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Lectura anterior</b></th>
                                <th style="background-color: #CACACA;width: 30mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Valor</b></th>
                                <th style="background-color: #CACACA;width: 40mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Lectura actual</b></th>
                                <th style="background-color: #CACACA;width: 30mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Valor</b></th>
                                <th style="background-color: #CACACA;width: 30mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Per&iacute;odo</b></th>
                            </tr>               
                            <tbody>

                                <tr>
                                    <?php 
                                  
                                    foreach ($lectura as $j => $l): ?>
                                        <?php
                                        $lant = $l['lectura_anterior'];
                                        $lact = $l['lectura_actual'];
                                        $valormts3 = $unidadfuncional->getCategoriaAgua()->getValor()
                                        ?>
                                        <td style="width: 40mm ;font-size: 0.6em; font-family:arial;height: 5mm;text-align: center;"><?php echo date("d-m-Y", strtotime($l['fecha_lectura_anterior'])) ?></td>
                                        <td style="width: 30mm ;font-size: 0.6em; font-family:arial;height: 5mm;text-align: center;"><?php echo $l['lectura_anterior'] ?></td>
                                        <td style="width: 40mm ;font-size: 0.6em; font-family:arial;height: 5mm;text-align: center;"><?php echo date("d-m-Y", strtotime($l['fecha_lectura_actual'])) ?></td>
                                        <td style="width: 30mm ;font-size: 0.6em; font-family:arial;height: 5mm;text-align: center;"><?php echo $l['lectura_actual'] ?></td>
                                        <td style="width: 30mm ;font-size: 0.6em; font-family:arial;height: 5mm;text-align: center;"><?php echo $l['Periodo']['mes'] . "/" . $l['Periodo']['anio'] ?></td>
                                    <?php endforeach; ?>
                                </tr> 
                            </tbody>
                        </table>
                        
                    </td>
                </tr>
                <tr>
                    <td  style="text-align: right;height: 1em;font-size: 0.6em; font-family:arial;">
                        <p>
                            <?php echo "Total Consumo: $" . ($lact - $lant) * $valormts3 ?>
                        </p>
                    </td>
                </tr> 
                <tr><td></td></tr>
               <?php endif; ?>
               <?php if(count($conceptosfijos)> 0):?>
                <tr>                                         
                    <td width="100%;"> 
                      
                        <table border="1">
                            <tr>
                                <th style="background-color: #CACACA;width: 80mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Concepto Fijo</b></th>
                                <th style="background-color: #CACACA;width: 28mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Valor</b></th>
                                

                            </tr>
                            <tbody>
                                <?php foreach ($conceptosfijos as $i => $c): ?>
                                    <tr>
                                        <td style="width: 80mm ;font-size: 0.6em; font-family:arial;height: 5mm;text-align: center;"><?php echo $c['nombre']; ?></td>
                                        <td style="font-size: 0.6em; font-family:arial;margin: 3mm;height: 4mm;text-align: center;"><?php echo "$" . $c['valor']; ?></td>
                                    </tr>
                                    <?php $totalfijos += $c['valor']; ?>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                        
                      </td>
                </tr>
                <tr style="height: 20mm">
                    <td  style="text-align: right;height: 1em;font-size: 0.6em; font-family:arial;">
                        <p>
                            <?php echo "Total Conceptos fijos: $" . $totalfijos ?>
                        </p>
                    </td>
                </tr> 
                 <?php endif; ?>
                <tr>
                    <td></td>
                </tr>
                <?php if(count($conceptos)> 0): ?>
                 <tr>                                         
                    <td width="100%">                        
                        <table border="1">
                            <tr>
                                <th style="background-color: #CACACA;width: 80mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Concepto</b></th>
                                <th style="background-color: #CACACA;width: 28mm;height: 5mm;font-size: 0.7em; font-family:arial;text-align: center"><b>Valor</b></th>
                               
                            </tr>
                            <tbody>
                               
                                <?php foreach ($conceptos as $i => $c): ?>
                                    <tr>
                                        <td style="width: 80mm ;font-size: 0.6em; font-family:arial;height: 5mm;text-align: center;"><?php echo $c['nombre']; ?></td>
                                        <td style="font-size: 0.6em; font-family:arial;margin: 3mm;height: 4mm;text-align: center;"><?php echo "$" . $c['precio']; ?></td>
                                        
                                    </tr>
                                    <?php $total += $c['precio']; ?>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </td>
                </tr>
                 <tr style="height: 20mm">
                    <td  style="text-align: right;height: 1em;font-size: 0.6em; font-family:arial;">
                        <p>
                            <?php echo "Total Conceptos variables: $" . $total ?>
                        </p>
                    </td>
                </tr> 
                 <?php endif; ?>
            <br>
            <tr>
            <p style="font-size: 0.5em"><?php echo "Fecha de Vencimiento: " . date("d-m-Y") ?>
            <hr>
            </p>

            <td  style="text-align: right;height: 2em;font-size: 0.7em; font-family:arial;"><b>Total a pagar: $<?php echo $total+$totalfijos+(($lact - $lant) * $valormts3); ?></b> </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
